﻿using System.Security.Cryptography.X509Certificates;

namespace ConsoleApp220920
{   ///字符小游戏
    internal class Program
    {
        static void Main(string[] args)
        {
            //字符小游戏介绍
            Console.WriteLine("Hello!This is a character game. "+
                          "Click W/w/A/a/S/s/D/d to start, and click the space to exit.") ;
            //设置起始点坐标
            int a = 0;
            int b = 1;
            Console.SetCursorPosition(a, b);
            //循环输入并执行
            while (true)
            {
                //设置输入坐标变量
                var Move = Console.ReadKey().KeyChar;
                //清屏
                Console.Clear();
                switch (Move)
                {   
                    //输入W/w以向上移动
                    case 'W':
                    case 'w':
                        b--;
                        if (b<0) b=0;
                        break;
                    //输入A/a以向左移动
                    case 'A':
                    case 'a':
                        a--;
                        if (a<0) a=0;
                        break;
                    //输入S/s以向下移动
                    case 'S':
                    case 's':
                        b++;
                        if (b>50) b=50;
                        break;
                    //输入D/d以向右移动
                    case 'D':
                    case 'd':
                        a++;
                        if (a>50) a=50;
                        break;
                    //输入错误
                    default:                
                         Console.WriteLine("You have entered non specified characters，please re-enter.");
                         continue; 
                }
                //输出坐标改变后的字符串
                Console.SetCursorPosition(a, b);
                Console.WriteLine("Hello!");
    
            }
        }

            


            
    }
}
 